import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'Home',
    component: ()=>import(/* webpackChunkName: 'blogHome' */'@/page/BlogHome.vue'),
    meta:{title: '张林的个人博客'}
  },
{
    path: '/Essay',
    name: 'Essay',
    component: ()=>import(/* webpackChunkName: 'BlogEssay' */'@/page/BlogEssay.vue'),
    props:true,
    meta:{title: '文章'}
  },{
    path: '/:pathMatch(.*)',
    redirect:'/error'
  },{
    path: '/error',
    component: ()=>import(/* webpackChunkName: 'error' */'@/error/BlogError.vue'),
    meta:{title: '404错误'}
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

router.beforeEach((to,from,next)=>{
document.title=<any>to.meta.title;
next()
})

export default router
